﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Castle.ActiveRecord;
using NHibernate.Criterion;
using LIB;
using System.Collections;

public partial class admin_users_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            int pageIndex = ConvertUtility.ToInt32(Request.QueryString["page"]);
            if (pageIndex > 0)
                bindUser(pageIndex);
            else
                bindUser(1);
            lblMessage.Text = "";

        }
        catch (Exception ex) { }
    }


    protected void bindUser(int pageIndex)
    {
        try
        {
            Users_Info[] lstUser = Users_Info.FindAll(Order.Desc("id"));
            repUser.DataSource = lstUser;
            repUser.DataBind();
        }
        catch (Exception ex) { }
    }

    protected void btnDel_Click(object sender, EventArgs e)
    {
        try
        {
            string[] arrKeyDel = hidKeyDel.Value.Split('|');

            for (int i = 0; i < arrKeyDel.Length - 1; i++)
            {
                Users_Info userInfo = Users_Info.Find(Convert.ToInt32(arrKeyDel[i].Trim()));
                userInfo.DeleteAndFlush();
            }
            Response.Redirect("/admin/users/default.aspx");

        }
        catch (Exception ex)
        {
            lblMessage.Text = "Có lỗi xảy ra. Hãy thử lại";
            fail.Visible = true;
        }
    }
}